package org.orzeszek.transfer.comm;

import java.io.File;
import java.net.InetAddress;

import javax.media.jai.operator.FileLoadDescriptor;

/**
 * Provides method(s) that allow a user to host a file locally on their machine and
 * make it available for download over the Net.
 * 
 * @author Michael Gierasimiuk
 */
public class Uploader
{
  private final InetAddress address;
  private final int port;

  private final FileHelper fileManager;
  private final CommHelper commManager;
  
  /**
   * Creates a new {@link Uploader} instance.
   * 
   * @param address the address to use.
   * @param port the port to use.
   */
  public Uploader( final InetAddress address, final int port )
  {
    this.address = address;
    this.port = port;
    
    this.fileManager = new FileHelper();
    this.commManager = new CommHelper();
  }

  /**
   * Hosts the given {@link File} on the user's machine. The resulting string is
   * the URL from which the file may be downloaded.
   * 
   * @param aFile the file to host.
   * @return the URL of the hosted file.
   */
  public String host( File aFile )
  {
    return null;
  }

  /**
   * Gets the {@link InetAddress} implementation that the
   * {@link FileLoadDescriptor} is using. It is at this address that the file
   * will be hosted.
   * 
   * @return the address.
   */
  public InetAddress getAddress()
  {
    return this.address;
  }

  /**
   * Gets the port that incoming connections will be allowed on. The result is
   * an integer between 0 and 65535, inclusive.
   * 
   * @return the port for incoming connections, between 0 and 65535.
   */
  public int getPort()
  {
    return this.port;
  }

  /**
   * Gets the file manager.
   *
   * @return the file manager.
   */
  public FileHelper getFileManager()
  {
    return this.fileManager;
  }

  /**
   * Gets the communication manager.
   *
   * @return communication manager.
   */
  public CommHelper getCommManager()
  {
    return this.commManager;
  }
  
  /** TODO: DEBUGGING. */
  public static void main( String[] args )
  {
    
  }
}
